const getPeabyCard = function (name, game) {
    const plant = {
        // pea
        card_Peashooter: PeaShooter.new(game),
        card_repeaterpea: Repeater.new(game),
        card_snowpea: SnowPea.new(game),
        card_threepeashooter: Threepeater.new(game),
    }
    return plant[name]
}

const getShroombyCard = function (name, game) {
    const plant = {
        card_scaredyshroom: Scaredyshroom.new(game),

    }
    return plant[name]
}

const getFlowerbyCard = function (name, game) {
    const plant = {
        // flower
        card_sunshroom: Sunshroom.new(game),
        card_TwinSunflower: Twinsunflower.new(game),
        card_sunflower: SunFlower.new(game),
    }
    return plant[name]
}

const getBoombyCard = function (name, game) {
    const plant = {
        // boom
        card_jalapeno: Jalapeno.new(game),
        card_cherrybomb: Cherry.new(game),
    }
    return plant[name]
}

const getPotatoMinebyCard = function (name, game) {
    const plant = {
        // boom
        card_PotatoMine: PotatoMine.new(game),
    }
    return plant[name]
}

const getHypnoshroombyCard = function (name, game) {
    const plant = {
        card_hypnoshroom: Hypnoshroom.new(game),
    }
    return plant[name]
}

const getChomperbyCard = function (name, game) {
    const plant = {
        card_chomper: Chomper.new(game),
        card_squash: Squash.new(game),
    }
    return plant[name]
}


const getGarlicbyCard = function (name, game) {
    const plant = {
        card_Gralic: Garlic.new(game),
    }
    return plant[name]
}
const getSpikeweedbyCard = function (name, game) {
    const plant = {
        card_spikeweed: Spikeweed.new(game),
    }
    return plant[name]
}
const getIceshroombyCard = function (name, game) {
    const plant = {
        card_iceshroom: Iceshroom.new(game),
    }
    return plant[name]
}

const getOtherbyCard = function (name, game) {
    const plant = {
        card_wallnut: Wallnut.new(game),
        card_PumpkinHead: Pumpkin.new(game),
    }
    return plant[name]
}

const getCardbySeed = function (name) {
    const cs = {
        seed_peashooter: 'card_Peashooter',
        seed_garlic: 'card_Gralic',
        seed_potatoMine: 'card_PotatoMine',
        seed_twinSunflower: 'card_TwinSunflower',
        seed_wallNut: 'card_wallnut',
        seed_cherrybomb: 'card_cherrybomb',
        seed_chomper: 'card_chomper',
        seed_hypnoShroom: 'card_hypnoshroom',
        seed_iceShroom: 'card_iceshroom',
        seed_jalapeno: 'card_jalapeno',
        seed_repeater: 'card_repeaterpea',
        seed_snowPea: 'card_snowpea',
        seed_squash: 'card_squash',
        seed_sunFlower: 'card_sunflower',
        seed_sunShroom: 'card_sunshroom',
        seed_threepeater: 'card_threepeashooter',
        seed_pumpkinHead: 'card_PumpkinHead',
        seed_scaredyShroom: 'card_scaredyshroom',
        seed_spikeweed: 'card_spikeweed',


        // seed_blover: 'img/seed/Blover.png',
        // seed_cactus: 'img/seed/Cactus.png',
        // seed_coffeeBean: 'img/seed/CoffeeBean.png',
        // seed_doomShroom: 'img/seed/DoomShroom.png',
        // seed_flowerPot: 'img/seed/FlowerPot.png',
        // seed_spikerock: 'img/seed/Spikerock.png',
        // seed_starfruit: 'img/seed/Starfruit.png',

        // seed_fumeShroom: 'img/seed/FumeShroom.png',
        // seed_gatlingPea: 'img/seed/GatlingPea.png',
        // seed_gloomShroom: 'img/seed/GloomShroom.png',
        // seed_lilyPad: 'img/seed/LilyPad.png',
        // seed_plantern: 'img/seed/Plantern.png',
        // seed_puffShroom: 'img/seed/PuffShroom.png',
        // seed_seaShroom: 'img/seed/SeaShroom.png',
        // seed_splitPea: 'img/seed/SplitPea.png',
        // seed_sunFlowerLimpid: 'img/seed/SunFlowerLimpid.png',
        // seed_sunShroomLimpid: 'img/seed/SunShroomLimpid.png',
        // seed_tallNut: 'img/seed/TallNut.png',
        // seed_torchwood: 'img/seed/Torchwood.png',

    }
    // log(cs['card_Peashooter'])
    return cs[name]
}

let loadLevel = function (n) {
    n = n - 1
    let level = levels[n]
    return level
}

const sleep = time => {
    return new Promise(resolve => setTimeout(resolve, time)
    )
}
